import 'package:flutter/material.dart';
import 'package:flutter_app/manager/UserInfoManager.dart';
import 'package:flutter_app/utils/date_time_utils.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/**
 * @Description: 图片水印
 * @Author: 下雨了
 * @CreateDate: 2022-08-03 14:08
 * @UpdateUser: 更新者
 * @UpdateDate:  2022-08-03 14:08
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
///

final GlobalKey<_ImageWatermarkState> imageWatermarkKey = new GlobalKey();

class ImageWatermark extends StatefulWidget {
  final String? time; //时间
  final String? name; //拍摄人
  final String address; //地址
  final double? fontSize; //字体大小

  ImageWatermark({
    Key? key,
    this.time,
    this.name,
    required this.address,
    this.fontSize,
  }) : super(key: key);

  @override
  _ImageWatermarkState createState() {
    return _ImageWatermarkState();
  }
}

class _ImageWatermarkState extends State<ImageWatermark> {

  @override
  Widget build(BuildContext context) {

    final TextStyle textStyle = TextStyle(color: Colors.white, fontSize: widget.fontSize ?? 16.sp);

    return Directionality(
      textDirection: TextDirection.ltr,
      child: Container(
        padding: EdgeInsets.all(8.r),
        decoration: BoxDecoration(
          color: Colors.black26,
          borderRadius: BorderRadius.circular(4.r),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              "时间：${widget.time ?? DateTimeUtils.getNow()}",
              style: textStyle,
              textScaleFactor: ScreenUtil().textScaleFactor,
            ),
            Text(
              "拍摄人：${widget.name ?? UserInfoManager().getUserName()}",
              style: textStyle,
              textScaleFactor: ScreenUtil().textScaleFactor,
            ),
            Text(
              "拍摄地址：${widget.address}",
              style: textStyle,
              textScaleFactor: ScreenUtil().textScaleFactor,
              maxLines: 1,
            ),
          ],
        ),
      ),
    );
  }
}
